WebFileInfo
By: Paul S Cilwa |
Posted: 11/30/2024 |
|
Page Views: 1 |
HostPaths and SitePaths and OwnerPaths, Oh, My! |
When I was nearing completion of this site's latest code incarnation, I realized I needed a better way to handle
pathnames, especially the thumbnails representing each page, working correctly and consistently. That's why I created the
WebFileInfo class, which extends .NET's FileInfo class, to simplify
accessing pages within the website. It converts between different forms of pathnames: HostPath (relative
to the hosting computer, starting with "c:"), SitePath (relative to the site, starting with "\"),
and RelativePath (relative to the referencing page, starting with "..\" or no special leading characters
at all, in the case of a simple file in the same folder, for example, an image on a page). This class
became an essential building block I hadn't anticipated but ultimately helped me wrap my head
around the various ways a site must handle file paths.